//
//  MBVipItemView.m
//  Meboo
//
//  Created by kyo on 2024/4/29.
//

#import "MBVipItemView.h"

@interface MBVipItemView ()

@end

@implementation MBVipItemView

#pragma mark - Life Cycle
- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self setupUI];
    }
    return self;
}

#pragma mark - Public Metohd
- (void)setIsSelected:(BOOL)isSelected {
    _isSelected = isSelected;
    if (isSelected) {
        self.layer.borderWidth = 2;
        self.NumLab.textColor = HEXS(@"B92176");
        self.dateLab.textColor = HEXS(@"B92176");
        self.priceLab.textColor = HEXS(@"B92176");
    } else {
        self.layer.borderWidth = 0;
        self.NumLab.textColor = HEXS(@"666666");
        self.dateLab.textColor = HEXS(@"666666");
        self.priceLab.textColor = HEXS(@"666666");
    }
}

#pragma mark - Action
- (void)clickItem {
    if (self.clickBlock) {
        self.clickBlock(self.tag);
    }
}

#pragma mark - UI
- (void)setupUI {
    
    UITapGestureRecognizer *actionTap =[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickItem)];
    [self addGestureRecognizer:actionTap];
    
    self.backgroundColor = UIColor.whiteColor;
    self.layer.cornerRadius = MBHeightScale(10);
    
    self.layer.borderColor = HEXS(@"B92176").CGColor;
    self.layer.borderWidth = 0;
    self.layer.masksToBounds = YES;
    
    [self addSubview:self.dateLab];
    [self.dateLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self);
    }];
    
    [self addSubview:self.NumLab];
    [self.NumLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.bottom.equalTo(self.dateLab.mas_top).offset(MBHeightScale(-5));
    }];
    
    [self addSubview:self.priceLab];
    [self.priceLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.top.equalTo(self.dateLab.mas_bottom).offset(MBHeightScale(5));
    }];
}

#pragma mark - Setter && Getter

- (UILabel *)NumLab {
    if (!_NumLab) {
        _NumLab = [[UILabel alloc] init];
        _NumLab.textAlignment = NSTextAlignmentCenter;
        _NumLab.font = MBHelBoldFontSizeScale(28);
        _NumLab.textColor = HEXS(@"666666");
    }
    return _NumLab;
}

- (UILabel *)dateLab {
    if (!_dateLab) {
        _dateLab = [[UILabel alloc] init];
        _dateLab.textAlignment = NSTextAlignmentCenter;
        _dateLab.font = MBHelFontSizeScale(16);
        _dateLab.textColor = HEXS(@"666666");
    }
    return _dateLab;
}

- (UILabel *)priceLab {
    if (!_priceLab) {
        _priceLab = [[UILabel alloc] init];
        _priceLab.textAlignment = NSTextAlignmentCenter;
        _priceLab.font = MBHelBoldFontSizeScale(16);
        _priceLab.textColor = HEXS(@"666666");
    }
    return _priceLab;
}
@end

